#!/bin/bash
ver=2.0.1
yum install curl gcc openssl-devel libnl3-devel net-snmp-devel  libnfnetlink-devel -y
function install(){
        [ ! -d /opt/tools ] && mkdir /opt/tools
        cd /opt/tools/ && curl --progress http://keepalived.org/software/keepalived-${ver}.tar.gz | tar xz
        cd keepalived-${ver}
        ./configure --prefix=/usr/local/keepalived && make && make install
}
function configure(){
        mkdir -p /etc/keepalived
        cp /opt/tools/keepalived-2.0.1/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
        cp /opt/tools/keepalived-2.0.1/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
        cp /opt/tools/keepalived-2.0.1/keepalived/etc/init.d/keepalived /etc/init.d/
        chmod +x /etc/init.d/keepalived
        echo "PATH=/usr/local/keepalived/sbin:$PATH" >>/etc/profile.d/keepalived.sh
}
main(){
        install
        configure
}
main

